<?php


namespace app\api\lists;


use app\common\enum\PayEnum;
use app\common\model\RechargeOrder;

class RechargeLists extends BaseShopDataLists
{
    /**
     * @notes 充值记录列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author ljj
     * @date 2022/12/16 16:19
     */
    public function lists(): array
    {
        $lists = RechargeOrder::field('order_amount,create_time')
            ->where(['user_id' => $this->userId,'pay_status' => PayEnum::ISPAID])
            ->order('id', 'desc')
            ->select()
            ->toArray();

        return $lists;
    }

    /**
     * @notes 充值记录数量
     * @return int
     * @author ljj
     * @date 2022/12/16 16:20
     */
    public function count(): int
    {
        return RechargeOrder::where(['user_id' => $this->userId,'pay_status' => PayEnum::ISPAID])->count();
    }
}